package com.example.demo.Entity;


import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.HashMap;

public class User{

  private long id;
  private String name;
  private String email;
  private long phonenumber;
  private String password;
  private long identity;
  private long status;
  private java.sql.Timestamp createTime;
  private long gender;
  private String intro;
  private String avatar;
  private String organization;
  private String position;
  private java.sql.Date birthday;
  private long followingsNum;
  private long followersNum;

  /**
   * 默认的构造函数，创建空用户对象
   */
  public User() {

  }

  /**
   * 通过键值对设置实体的值
   * @param key 实体的属性名
   * @param value 实体属性要更改的值(String格式)
   *
   */
  public void setAttribute(String key,String value){

    switch (key){
      case "id":
        this.setId(Integer.parseInt(value));
        break;
      case "name":
        this.setName((String) value);
        break;
      case "email":
        this.setEmail((String) value);
        break;
      case "phonenumber":
        this.setPhonenumber(Integer.parseInt(value));
        break;
      case "password":
        this.setPassword((String) value);
        break;
      case "identity":
        this.setIdentity(Integer.parseInt(value));
        break;
      case "status":
        this.setStatus(Integer.parseInt(value));
        break;
      case "createTime":
        this.setCreateTime( new Timestamp(Integer.parseInt(value)));
        break;
      case "gender":
        this.setGender(Integer.parseInt(value));
        break;
      case "intro":
        this.setIntro((String) value);
        break;
      case "avatar":
        this.setOrganization((String) value);
        break;
      case "position":
        this.setPosition((String) value);
        break;
      case "birthday":
        this.setBirthday(new Date(Integer.parseInt(value)));
        break;
      case "followingsNum":
        this.setFollowingsNum(Integer.parseInt(value));
        break;
      case "followersNum":
        this.setFollowersNum(Integer.parseInt(value));
        break;


      default:
        break;
    }

    return;
  }
  /**
   * 通过键值对设置实体的值
   * @param key 实体的属性名
   * @param value 实体属性要更改的值(object会被强制类型转换)
   *
   */
  public void setAttribute(String key,Object value){

    switch (key){
      case "id":
        this.setId((Long) value);
        break;
      case "name":
        this.setName((String) value);
        break;
      case "email":
        this.setEmail((String) value);
        break;
      case "phonenumber":
        this.setPhonenumber((Long) value);
        break;
      case "password":
        this.setPassword((String) value);
        break;
      case "identity":
        this.setIdentity((Long) value);
        break;
      case "status":
        this.setStatus((Long) value);
        break;
      case "createTime":
        this.setCreateTime((Timestamp) value);
        break;
      case "gender":
        this.setGender((Long) value);
        break;
      case "intro":
        this.setIntro((String) value);
        break;
      case "avatar":
        this.setOrganization((String) value);
        break;
      case "position":
        this.setPosition((String) value);
        break;
      case "birthday":
        this.setBirthday((Date) value);
        break;
      case "followingsNum":
        this.setFollowingsNum((Long) value);
        break;
      case "followersNum":
        this.setFollowersNum((Long) value);
        break;


      default:
        break;
    }

    return;
  }

  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }


  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }


  public long getPhonenumber() {
    return phonenumber;
  }

  public void setPhonenumber(long phonenumber) {
    this.phonenumber = phonenumber;
  }


  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }


  public long getIdentity() {
    return identity;
  }

  public void setIdentity(long identity) {
    this.identity = identity;
  }


  public long getStatus() {
    return status;
  }

  public void setStatus(long status) {
    this.status = status;
  }


  public java.sql.Timestamp getCreateTime() {
    return createTime;
  }

  public void setCreateTime(java.sql.Timestamp createTime) {
    this.createTime = createTime;
  }


  public long getGender() {
    return gender;
  }

  public void setGender(long gender) {
    this.gender = gender;
  }


  public String getIntro() {
    return intro;
  }

  public void setIntro(String intro) {
    this.intro = intro;
  }


  public String getAvatar() {
    return avatar;
  }

  public void setAvatar(String avatar) {
    this.avatar = avatar;
  }


  public String getOrganization() {
    return organization;
  }

  public void setOrganization(String organization) {
    this.organization = organization;
  }


  public String getPosition() {
    return position;
  }

  public void setPosition(String position) {
    this.position = position;
  }


  public java.sql.Date getBirthday() {
    return birthday;
  }

  public void setBirthday(java.sql.Date birthday) {
    this.birthday = birthday;
  }


  public long getFollowingsNum() {
    return followingsNum;
  }

  public void setFollowingsNum(long followingsNum) {
    this.followingsNum = followingsNum;
  }


  public long getFollowersNum() {
    return followersNum;
  }

  public void setFollowersNum(long followersNum) {
    this.followersNum = followersNum;
  }

}
